//
//  AlarmListTableViewCell.m
//  StormWatch
//
//  Created by Hero on 2024/9/5.
//

#import "AlarmListTableViewCell.h"


@implementation AlarmListTableViewCell
- (void)setModel:(AlermModel *)model {
    _model = model;
    self.timeLab.text = [NSString stringWithFormat:@"%02lu:%02lu",model.alert_H,  model.alert_M];
    if (model.isOpen == 0) {
        self.switchbtn.on = NO;
    }else {
        self.switchbtn.on = YES;
    }
    
    if ([model.repeat hasSuffix:@"0"]) {
        self.dateLab.text = SWString(@"once");
    }else {
        // 00111110
        NSMutableArray * arr = [[NSMutableArray alloc] init];
        for (int i = 6; i >= 0; i --) {
            if ([[model.repeat substringWithRange:NSMakeRange(i, 1)] isEqualToString:@"1"]) {
                [arr insertObject:WeekList[i] atIndex:0];
            }
        }
        self.dateLab.text = [arr componentsJoinedByString:@" "];
    }
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = 0;
    // Initialization code
}
- (IBAction)clickSwithBtn:(UISwitch *)sender {
    self.model.isOpen = sender.isOn;
    
    
    self.changeBlock(self.model);
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
